package com.ys.http.utils;

import java.net.FileNameMap;
import java.net.URLConnection;

public class MimeTypeUtils {

    public static String getMimeType(String name) {
        return getMimeType(name, null);
    }

    public static String getMimeType(String name, String def) {
        if (name == null) {
            return def;
        }
        FileNameMap nameMap = URLConnection.getFileNameMap();
        String mineType = nameMap.getContentTypeFor(name);
        if (mineType == null) {
            return def;
        }
        return mineType;
    }

}
